@extends('default.layouts.adminPublic')
@section('title', '广告列表管理')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/ad_list')}}">首页</a> &raquo; 广告列表管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->

    <div class="con">
        <div class="conMain">
            <div class="result_wrap" >
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/ad_list')}}" method="post">
                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="请输入广告名称" type="text"></span>
                        <select name="ad_site" id="ad_site" style="width:140px;">
                            <option value="">请选择广告站点</option>
                            @if(count($ad_site) > 0)
                                @foreach($ad_site as $v )
                                    <option value="{{$v->id}}">{{$v->site_name}}</option>
                                @endforeach
                            @endif
                        </select>
                        <select name="ad_slots" id="ad_slots" style="width:140px;">
                            <option value="">请选择广告位置</option>
                            @if(count($as_slots) > 0)
                                @foreach($as_slots as $v )
                                    <option value="{{$v->id}}">{{$v->ad_name}}</option>
                                @endforeach
                            @endif
                        </select>
                        <select name="status" id="status" style="width:140px;">
                            <option value="">请选择发布状态</option>
                            <option value="1">发布中</option>
                            <option value="2">屏蔽中</option>
                        </select>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                </div>
                <div class="message" style="margin-top: 15px;">
                    <p><span style="margin-right: 20px; font-size: 15px;"><a href="{{url('admin/ad_manage/create')}}"><i class="fa fa-plus"></i>添加广告</a></span>
                       <span>目前共查找到<strong>{{$ad_manage->total()}}</strong>个广告！且每页显示广告记录{{$ad_manage->perPage()}}个。</span>
                    </p>
                </div>
            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt><input name="selectall" type="checkbox" value="1" onclick="CheckAll(this)" /></dt>
                            <dd class="ad1">广告名称</dd>
                            <dd class="ad2">到期时间</dd>
                            <dd class="ad3">图片地址</dd>
                            <dd class="ad4">广告站点</dd>
                            <dd class="ad5">广告位置</dd>
                            <dd class="ad6">发布状态</dd>
                            <dd class="ad7">广告操作</dd>
                        </dl>
                        @if(count($ad_manage) > 0 )
                            @foreach($ad_manage as $v)
                                <dl id="list{{$v->id}}">
                                    <dt><input name="selected_id[]" type="checkbox" value="{{$v->id}}" /></dt>
                                    <dd class="ad1"><a href="{{$v->ad_url}}" target="_blank">{{str_limit($v->title,24)}}</a></dd>
                                    <dd class="ad2">@if($v->end_time >= date('Y-m-d',time()))<span style="color: #ff4400">{{$v->end_time}}</span>@else{{$v->end_time}}@endif</dd>
                                    <dd class="ad3"><span style="margin-top: 8px; float: left;"><a href="{{asset('upload/adminad/'.$v->pic_url)}}" target="_blank"><img src="{{asset('upload/adminad/'.$v->pic_url)}}" width="26" height="26"></a></span><span style="float: left;"><a target="_blank" href="{{url('/admin/ad_slots/'.$v->ad_slots."?ad_id=".$v->id)}}">调整位置</a></span></dd>
                                    <dd class="ad4">{{$v->ad_site}}</dd>
                                    <dd class="ad5">{{$v->ad_slots_name}}</dd>
                                    <dd class="ad6">@if($v->status == '1')<span  style="color: #2ca02c">发布中</span>@else<span  style="color: #bbb">屏蔽中</span>@endif</dd>
                                    <dd class="ad7">
                                        <span><a href="{{url('admin/ad_manage/'.$v->id.'/edit')}}">修改广告</a></span>
                                        <span><a onclick="delAd({{$v->id}})">删除广告</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有广告条件的记录！</div>
                        @endif
                        <dl class="last">
                            <dt>
                                <input name="selectall" id="selectall" type="checkbox" value="1" onclick="CheckAll(this)" />
                                <label for="selectall">全选</label>
                            </dt>
                            <dd class="p6"><a onclick="showconfirm('{{url('admin/activation')}}','1')">激活广告</a></dd>
                            <dd class="p6"><a onclick="showconfirm('{{url('admin/shield')}}','2')">屏蔽广告</a></dd>
                        </dl>
                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $ad_manage->appends($input)->links() !!}
                </div>
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/admin/advertising.js')}}"></script>
    <script>
        //删除广告
        function delAd(id) {
            layer.confirm('您确定要删除这份广告吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("{{url('admin/ad_manage/')}}/" + id, {'_method': 'delete','_token': "{{csrf_token()}}"}, function (data) {
                    if (data.status == 0) {
                        layer.msg(data.msg, {icon: 6,time:1500});
                        $("#thisForm").find('#conList').find("#list"+id).remove();
                    } else {
                        layer.msg(data.msg, {icon: 5,time:1500});
                    }
                });
            });
        }
      </script>
@endsection